using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using LibKetoan;

namespace Ketoan
{
	/// <summary>
	/// Summary description for Print.
	/// </summary>
	public class Print
	{
		public Print(){}
		public void Printer(AccessData m,DataSet ds,string tenfile,string c1,string c2,int kieu)
		{
			try
			{
				ReportDocument oRpt=new ReportDocument();
				oRpt.Load("..\\..\\..\\report_ttb\\"+tenfile,OpenReportMethod.OpenReportByTempCopy);
				oRpt.SetDataSource(ds);
				if (c1!="")
				{
					oRpt.DataDefinition.FormulaFields["s_nguoithu"].Text="'"+c1+"'";
					oRpt.DataDefinition.FormulaFields["s_sovaovien"].Text="'"+c2+"'";
				}
				oRpt.PrintOptions.PaperSize=PaperSize.PaperA4;
				oRpt.PrintOptions.PaperOrientation=(kieu==1)?PaperOrientation.Portrait:PaperOrientation.Landscape;
				oRpt.PrintToPrinter(1,false,0,0);
				oRpt.Close(); oRpt.Dispose();
			}
			catch(Exception ex){MessageBox.Show(ex.Message);}
		}
		public void Printer(AccessData m,DataSet ds,string tenfile,string c1,string c2,string c3,string c4,string c5,string c6,string c7,string c8,string c9,string c10,int kieu,int copy)
		{
			try
			{
				ReportDocument oRpt=new ReportDocument();
				oRpt.Load("..\\..\\..\\report_ttb\\"+tenfile,OpenReportMethod.OpenReportByTempCopy);
				oRpt.SetDataSource(ds);
				oRpt.DataDefinition.FormulaFields["soyte"].Text="'"+m.Syte+"'";
				oRpt.DataDefinition.FormulaFields["benhvien"].Text="'"+m.Tenbv+"'";
				oRpt.DataDefinition.FormulaFields["c1"].Text="'"+c1+"'";
				oRpt.DataDefinition.FormulaFields["c2"].Text="'"+c2+"'";
				oRpt.DataDefinition.FormulaFields["c3"].Text="'"+c3+"'";
				oRpt.DataDefinition.FormulaFields["c4"].Text="'"+c4+"'";
				oRpt.DataDefinition.FormulaFields["c5"].Text="'"+c5+"'";
				oRpt.DataDefinition.FormulaFields["c6"].Text="'"+c6+"'";
				oRpt.DataDefinition.FormulaFields["c7"].Text="'"+c7+"'";
				oRpt.DataDefinition.FormulaFields["c8"].Text="'"+c8+"'";
				oRpt.DataDefinition.FormulaFields["c9"].Text="'"+c9+"'";
				oRpt.DataDefinition.FormulaFields["c10"].Text="'"+c10+"'";
				oRpt.DataDefinition.FormulaFields["giamdoc"].Text="";
				oRpt.DataDefinition.FormulaFields["phutrach"].Text="";
				oRpt.DataDefinition.FormulaFields["thongke"].Text="";
				oRpt.DataDefinition.FormulaFields["ketoan"].Text="";
				oRpt.DataDefinition.FormulaFields["thukho"].Text="";
				oRpt.PrintOptions.PaperSize=PaperSize.PaperA4;
				oRpt.PrintOptions.PaperOrientation=(kieu==1)?PaperOrientation.Portrait:PaperOrientation.Landscape;
				oRpt.PrintToPrinter(copy,false,0,0);
				oRpt.Close(); oRpt.Dispose();
			}
			catch(Exception ex){MessageBox.Show(ex.Message);}
		}

		public void Printer(AccessData kt,DataSet ds,string sTungay,string sTieude,string sNguoiky,string report,int kieu,int copy)
		{
			try
			{
				ReportDocument oRpt=new ReportDocument();
				oRpt.Load("..\\..\\..\\report\\"+report,OpenReportMethod.OpenReportByTempCopy);
				oRpt.SetDataSource(ds);
				oRpt.DataDefinition.FormulaFields["SoYTe"].Text="'"+kt.Syte+"'";
				oRpt.DataDefinition.FormulaFields["BenhVien"].Text="'"+kt.Tenbv+"'";
				oRpt.DataDefinition.FormulaFields["Ngaythang"].Text="'"+sTungay+"'";
				oRpt.DataDefinition.FormulaFields["Tieude"].Text="'"+sTieude+"'";
				oRpt.DataDefinition.FormulaFields["Text1"].Text="'"+sNguoiky+"'";
				oRpt.DataDefinition.FormulaFields["Text2"].Text="";
				oRpt.DataDefinition.FormulaFields["Text3"].Text="";
				oRpt.DataDefinition.FormulaFields["Text4"].Text="";
				oRpt.PrintOptions.PaperSize=PaperSize.DefaultPaperSize;
				oRpt.PrintOptions.PaperOrientation=(kieu==1)?PaperOrientation.Portrait:PaperOrientation.Landscape;
				oRpt.PrintToPrinter(copy,false,0,0);
			}
			catch(Exception ex){MessageBox.Show(ex.Message);}
		}

		public void Printer(AccessData kt,DataSet ds,string sTungay,string sTieude,string sNguoiky,string Text2,string Text3,string Text4,string report,int kieu,int copy)
		{
			try
			{
				ReportDocument oRpt=new ReportDocument();
				oRpt.Load("..\\..\\..\\report\\"+report,OpenReportMethod.OpenReportByTempCopy);
				oRpt.SetDataSource(ds);
				oRpt.DataDefinition.FormulaFields["SoYTe"].Text="'"+kt.Syte+"'";
				oRpt.DataDefinition.FormulaFields["BenhVien"].Text="'"+kt.Tenbv+"'";
				oRpt.DataDefinition.FormulaFields["Ngaythang"].Text="'"+sTungay+"'";
				oRpt.DataDefinition.FormulaFields["Tieude"].Text="'"+sTieude+"'";
				oRpt.DataDefinition.FormulaFields["Text1"].Text="'"+sNguoiky+"'";
				oRpt.DataDefinition.FormulaFields["Text2"].Text=Text2;
				oRpt.DataDefinition.FormulaFields["Text3"].Text=Text3;
				oRpt.DataDefinition.FormulaFields["Text4"].Text=Text4;
				oRpt.PrintOptions.PaperSize=PaperSize.DefaultPaperSize;
				oRpt.PrintOptions.PaperOrientation=(kieu==1)?PaperOrientation.Portrait:PaperOrientation.Landscape;
				oRpt.PrintToPrinter(copy,false,0,0);
			}
			catch(Exception ex){MessageBox.Show(ex.Message);}
		}

		public void Printer(AccessData m,DataSet ds,string tenfile,string msg,int kieu)
		{
			try
			{
				ReportDocument oRpt=new ReportDocument();
				oRpt.Load("..\\..\\..\\report_ttb\\"+tenfile,OpenReportMethod.OpenReportByTempCopy);
				oRpt.SetDataSource(ds);
				oRpt.DataDefinition.FormulaFields["SoYTe"].Text="'"+m.Syte+"'";
				oRpt.DataDefinition.FormulaFields["BenhVien"].Text="'"+m.Tenbv+"'";
				oRpt.DataDefinition.FormulaFields["TenBenhAn"].Text="'"+msg+"'";
				oRpt.PrintOptions.PaperSize=PaperSize.PaperA4;
				oRpt.PrintOptions.PaperOrientation=(kieu==1)?PaperOrientation.Portrait:PaperOrientation.Landscape;
				oRpt.PrintToPrinter(1,false,0,0);
				oRpt.Close(); oRpt.Dispose();
			}
			catch(Exception ex){MessageBox.Show(ex.Message);}
		}
	}
}
